package instructions;

import memory.Address;
import memory.Memory;
import memory.Word;
import Computer.ProgramCounter;

public class JumpEq implements Instruction {
	private int jumpTo;
	private Address address;
	private Word word;
	
	public JumpEq(int jumpTo, Address address, Word word){
		this.address = address;
		this.word = word;
		this.jumpTo = jumpTo;
	}
	
	public void execute(Memory memory, ProgramCounter counter) {
		if (memory.getWord(address).equals(word))
			counter.setCounter(jumpTo);
		else
			counter.increase();
	}
	
	public String toString(){
		return "JEQ " + jumpTo + " [" + address + "] " + word +"\n";
	}

}
